package com.hrt.datasender.web.bcmonitorparamdict;

import java.util.List;

import com.btcode.orm.model.ModelPageResult;
import com.hrt.datasender.datadao.model.BcMonitorParamDictModel;
import com.hrt.db.DBManager;

public final class BcMonitorParamDictService {

    private static volatile BcMonitorParamDictService instance;

    private BcMonitorParamDictService() {

    }

    public static BcMonitorParamDictService getInstance() {
        if (instance == null) {
            synchronized (BcMonitorParamDictService.class) {
                if (instance == null) {
                    instance = new BcMonitorParamDictService();
                }
            }
        }
        return instance;
    }

    public void create(BcMonitorParamDictModel model) {
        DBManager.getORMExecuter().create(model);
    }

    public void update(BcMonitorParamDictModel model) {
        DBManager.getORMExecuter().update(model);
    }

    public void delete(String id) {
        BcMonitorParamDictModel model = new BcMonitorParamDictModel();
        model.setId(id);
        DBManager.getORMExecuter().delete(model);
    }

    public List<BcMonitorParamDictModel> getList() {
        ModelPageResult mpr = DBManager.getORMExecuter().getModelList(BcMonitorParamDictModel.class,
                null,null);
        List<BcMonitorParamDictModel> models = mpr.getData();
        return models;
    }

    public BcMonitorParamDictModel getModel(BcMonitorParamDictModel testModel) {
        List<BcMonitorParamDictModel> models = DBManager.getORMExecuter().getModels(testModel);
        BcMonitorParamDictModel model = models.get(0);
        return model;
    }
}
